﻿//-----------------------------------------------------------------------
// <copyright file="ReadOnlyCheckBox.cs" company="Forebrain Technology, LLC">
//
// Copyright (c) Forebrain Technology, LLC. All rights reserved.
// 
// This source code is released under the Microsoft Public License (Ms-PL).
//
// </copyright>
//-----------------------------------------------------------------------
namespace PivotCollectionMaker.WinFormApplication.Controls
{
    using System;
    using System.Windows.Forms;

    /// <summary>
    /// Represents a readonly CheckBox
    /// </summary>
    public class ReadOnlyCheckBox : CheckBox
    {
        /// <summary>
        /// Gets or sets a value indicating whether [read only].
        /// </summary>
        /// <value><c>true</c> if [read only]; otherwise, <c>false</c>.</value>
        public bool ReadOnly { get; set; }

        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Click"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
        protected override void OnClick(EventArgs e)
        {
            // pass the event up only if its not readlonly
            if (!this.ReadOnly)
            {
                base.OnClick(e);
            }
        }
    }
}